<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 高配版的节流 => 达到一个节流的封装*/

        //业务代码
        function fn(e) {
            console.group();
            console.log(e);
            console.groupEnd();
        }

        // 节流代码
        function throttle(fn, time) {
            //节流代码
            let firstTime = 0;
            return function(){
                let nowTime = +new Date();
                if(nowTime - firstTime < time){
                    return;
                }
                firstTime = nowTime;
                // fn(e); 
                fn.call(this,arguments[0])
            }
        }

        //触发事件
        document.onmousemove = throttle(fn,1000)
    </script>
</body>

</html>